package leetcode11

// 双指针往里走

func maxArea(height []int) int {
	var (
		left    = 0
		right   = len(height) - 1
		maxArea = 0
	)
	if len(height) <= 1 {
		return maxArea
	}

	for left < right {
		maxArea = maxInt(maxArea, (right-left)*minInt(height[left], height[right]))
		if height[left] < height[right] {
			left++
		} else {
			right--
		}

	}
	return maxArea
}

func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func minInt(x, y int) int {
	if x > y {
		return y
	}
	return x
}
